package com.tgy.service;

import com.tgy.entity.Dept;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.ArrayList;
import java.util.List;

/***
 * @ClassName: DeptClientServiceFallbackFactory
 * @Description:
 * @Auther: 送一一块二向箔
 * @Date: 15:08 2022/1/17
 * @version : V1.0
 */
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory<DeptClientService> {
    @Override
    public DeptClientService create(Throwable cause) {
        return new DeptClientService() {
            @Override
            public String test() {
                return "没有对应的信息，客户端提供了降级的信息，这个服务现在已经被关闭";
            }

            @Override
            public List<Dept> all() {
                return null;
            }

            @Override
            public List<Dept> list(Dept dept) {
                List<Dept> lists = new ArrayList<>();

                Dept aa = new Dept().setDeptNo(0000L)
                        .setDeptName("这个id=>" + dept.getDeptNo() + "没有对应的信息，客户端提供了降级的信息，这个服务现在已经被关闭")
                        .setDbSource("Hystrix");
                lists.add(aa);
                return lists;
            }

            @Override
            public Boolean add(Dept dept) {
                return true;
            }

            @Override
            public Boolean upd(Dept dept) {
                return true;
            }

            @Override
            public Integer delR(Long id) {
                return null;
            }

            @Override
            public Integer del(Long id) {
                return null;
            }

            @Override
            public Dept id(Long id) {
                return new Dept().setDeptNo(0000L)
                        .setDeptName("这个id=>" + id + "没有对应的信息，客户端提供了降级的信息，这个服务现在已经被关闭")
                        .setDbSource("Hystrix");
            }
        };
    }
}
